package com.qiujie.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qiujie.entity.Dept;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface DeptMapper extends BaseMapper<Dept> {

    /**
     * 查找员工所在的部门
     */
    @Select("SELECT sd.* " +
            "FROM sys_staff ss " +
            "LEFT JOIN sys_dept sd " +
            "  ON sd.id = ss.dept_id " +
            "  AND sd.is_deleted = 0 " +
            "WHERE ss.is_deleted = 0 " +
            "  AND ss.id = #{id}")
    Dept queryByStaffId(@Param("id") Integer id);

}
